<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
    <script type="text/javascript">

        function demo(){
            //获取当前日期
            var nowDate=new Date();
            //截止日期
            var endDate=new Date('2019/9/4 20:00:00');
            var diffTime=parseInt((endDate.getTime()-nowDate.getTime())/1000);
            var a=document.querySelector("#shi");
            var b=document.querySelector("#fen");
            var c=document.querySelector("#miao");
            //将时间转化为时 分 秒
            var hour,minute,second;

            second=diffTime%60;//秒
            minute=parseInt(diffTime/60)%60;
            hour=parseInt(diffTime/60/60);

//            var time='剩余：'+hour+'小时'+minute+'分钟'+second+'秒';
//            document.body.innerHTML=time;
                a.innerHTML=hour;
                b.innerHTML=minute;
                c.innerHTML=second;
            setTimeout(demo,1000);
        }
        // demo();

        // setInterval('demo()',1000);
        // demo();
        // setInterval(demo,1000);
    </script>
</head>
<body>

<div class="jd">
    <h1>京东秒杀</h1>
    <p>20点场倒计时</p>
    <div id="shi"></div>



    <div id="fen"></div>
    <div id="miao"></div>
    <div class="dian">:</div>
    <div class="dianzi">:</div>
</div>














<script type="text/javascript">
    demo();
</script>
</body>
</html>

